#include <string.h>
#include <stdint.h>
#include <stdbool.h>

#include "heap.h"
#include "dram_mem.h"

#define configTOTAL_DRAM_HEAP_SIZE  ( ( 15 * 1024 ) )

static bool is_mem_poll_inited = false;

__attribute__((section("dram_section"))) static uint32_t ucHeap[ (configTOTAL_DRAM_HEAP_SIZE >> 2) + 0x10];

void * dram_malloc( uint32_t xWantedSize )
{
    if (is_mem_poll_inited == false) {
        is_mem_poll_inited = true;
        heap_mem_init(HEAP_TYPE_DRAM_BLOCK, (void *)ucHeap, configTOTAL_DRAM_HEAP_SIZE);
    }
    
    return heap_mem_alloc(HEAP_TYPE_DRAM_BLOCK, xWantedSize);
}

void dram_free( void * pv )
{
    heap_mem_free(pv);
}

